package mn.slide.labmed;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

public class HomeActivity extends Activity
{
	private Button	humanbtn , mikrobtn , laborbtn , har;
	@Override
	public void onCreate( Bundle savedInstanceState )
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);
		har = (Button) findViewById(R.id.button1);
		har.setVisibility(View.INVISIBLE);
		humanbtn = (Button) findViewById(R.id.humanbtn);
		mikrobtn = (Button) findViewById(R.id.mikrobtn);
		laborbtn = (Button) findViewById(R.id.labor_btn);
		laborbtn.setOnClickListener(new OnClickListener()
		{
			public void onClick( View v )
			{
				Pathlayout.path.clear();
				Pathlayout.path.add("Laboratoriumsmedizin");
				HomeTabGroupActivity.group.goLabMedListActivity("1", "main");

			}
		});
		humanbtn.setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				Pathlayout.path.clear();
				Pathlayout.path.add("Humangenetik");
				HomeTabGroupActivity.group.goLabMedListActivity("3", "main");
			}
		});
		mikrobtn.setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				Pathlayout.path.clear();
				Pathlayout.path.add("Mikrobiologie");
				HomeTabGroupActivity.group.goLabMedListActivity("4", "main");
			}
		});
		final EditText searchbox = (EditText) findViewById(R.id.home_search);

		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(searchbox.getWindowToken(), 0);

		searchbox.setOnKeyListener(new View.OnKeyListener()
		{

			public boolean onKey( View v , int keyCode , KeyEvent event )
			{

				if (keyCode == KeyEvent.KEYCODE_ENTER)
				{
					EditText searchbox = (EditText) v;
					InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
					imm.hideSoftInputFromWindow(searchbox.getWindowToken(), 0);
					HomeTabGroupActivity.group.goSearchActivity(searchbox.getText().toString());
				}
				return false;
			}
		});
	}

}
